package com.labi.designpattern.service;

import com.labi.designpattern.enums.OrderEvent;
import org.springframework.messaging.Message;
import org.springframework.statemachine.annotation.OnTransition;
import org.springframework.statemachine.annotation.WithStateMachine;
import org.springframework.stereotype.Component;

import java.util.Objects;

@Component
@WithStateMachine(name = "orderStateMachine")  //这样 可以监听  ,名字对上了
//@Slf4j
public class OrderStateListenerV2 {

    @OnTransition(source = "CREATED", target = "WAIT_CHECKED")
    public void onPayStart(Message<OrderEvent> message) {
//        message.getHeaders().get()
//        PaymentRequest request = (PaymentRequest) message.getHeaders().get("request");
        String header = message.getHeaders().get("headerName1").toString();
        String orderId = message.getHeaders().get("orderId").toString();
        System.out.println("V2开始处理库存状态检查请求,接收到headername " + header + "  接收到订单号" + orderId);
//        System.out.println( message.getTransactionId());
    }
}